//
//  Question.m
//  iSuDoku
//
//  Created by maccctk on  9-6-24.
//  Copyright 2  9 __MyCompanyName__. All rights reserved.
//

#import "Question.h"

@implementation Question

char *glist[]  = {
"1061030020050008107000007034009006078003209500570300900190700000802400060040010250",
"1100830002570001000000509064704008590003010400051400306360704000000600079800052003",
"1030007004602041000050030967040003006087000350900700020718020040000160809400500030",
"1085000210094012003000300704503409000040206030000103907608005000100840360027000890",
"2007000900200507006080104070040010030601000809090080060050809010100603002006000300",
"2070103060050000070300050001500304008407000102900702004200070003030000040060509020",
"2000013400080006950650000000960201000100070002000304016000000079025800040009760000",
"2001090270009002050200003000300014002080000040100280005000900007010300900046070500",
"2000409000080020700020507106300800060760000031010006002205908040009070010000605000",
"2000000945006000000520103807090310000003080100000046020705208019000000300861000000",
"2200700050000048006000002309900600240070020080025001003804900000600480000090003008",
"2065000300200067900040300001006050004000402000700080100600004010008570006001000830",
"2027900000050002084008000207070030006000817000300040020106000800240600010000005640",
"2900278100001030249003000000030800000007000500000004030000000300578040900004516007",
"2006007009800030100900605030003000018000901000210000600060703001009020004700800500",
"2470108029000000000006927100090601030300000004040709080004875300000000000580403097",
"2050801090730000054800030001008302100000000000006704500100050009380000012040608030",
"2653000700000009000804050003900017300005030800007290005400070206000800000006000157",
"8010000060300000009250400300470310000020070040000046078003008057800000004060000010",
"2024861000170020005000000000701003080900050004080900501000000000300080017000692450",
"2001309700700000006560000018040693070000050000070482050630000081200000009004901300",
"2008600002390002000004370000003000810602010304015000200000063700000500049200008100",
"2100900670000400013090020000000572030300000005020394000000040020260005000085003009",
"2000000004028750030031002000650237000000090000000681059000900860090024310500000000",
"2000050000060409010170000094086000540400703008021000670240000087010904030000030000",
"2645900003700000000030006804000050039100307002420090000204800090000000005500009416",
"2005000006400209000370060008040006007080050020100300090500080032000907001600000700",
"2000090030000860120000342860007000205008000600201000400035276000016084000020050000",
"2052083940000000000140007320008009000039000760000700500067500091000000000014670830",
"2000000003000590400820004605006005200500106009001200300108900047007083000200000000",
"3000100260700030000302080400000408001035000940200305000006050709000040008057009000",
"3008090000070000280064100309000805900500000001009304000802007560097000010000060700",
"3000702000100040007650000094470801062000000000580209013860000075900060008000908000",
"3007238000060700050000400002900000867100000003648000005700003000020005030000174900",
"3507000009080002170010060004090030000001709300000040060800050020076200090400000608",
"3009700000500002709800010006001600405000040000706008200400090008602300004000007900",
"3009000064400000000100360072004600009000903000200005400920057008000000005340000600",
"3030008005005000807000040900000390400059070210002065000007050000501000700600900020",
"3302700009008000045004001300000059000090030060000260000001400200260000100400002503",
"3095008000002006700040000005050020007060050020400070080200000040006100300000300250",
"3003000400007208500800030007200703004005000800700501009100040002006809700004000900",
"3000009752090000000140800009009502006000308000700104500600003025000000010524600000",
"3120000008006009040000005006050070310000504000072030060600700000040600500900000037",
"3200000007007610000009007260004060070050409030020070500086700900000084300400000008",
"3000000000500009062870050030100040520300906001084020003010060047740800009000000000",
"3480600130000800007200905600100007800000000000002300001004209005900001000023006018",
"3600090180030006700700000020500024000000603000000980007020000008009100070087050009",
"3850100300300000007040000020010080700900305008005020090030000070500000001001002064",
"3501030007080000060000006004003961000800503009000728600100300000020000030900070801",
"3700010054090000001005800060400680000100040003000039002020006100300000020570020008",
"3180000400000800000009034500040960000520080076000053010002510700000002000007000092",
"3930000076500470002000093000009000060067000180020000300000540000200068003140000025",
"3060030000045900028008000730000090050900806007080050000036000900420009380000020010",
"3400000005103000400000003060300590208000807000809061007020400000001000506500000009",
"3506400108000800000709300204000000379000000000213000000805004702000005000301002906",
"3870000021000682000090000030006704300009000200008203400060000090000409000920000048",
"3000403000040010060270000049900501003007000500800206004760000032030020090000304000",
"3300000008000241000706000902050406030008000700090108050902000403000324000400000007",
"3000006200300020890010700030053000060002000100080000940030001080027030006009800000",
"3350200006000030002000106000001070509080604070607010200000405000100060000700001038",
"3007065000000000040060700830600000020970203061050000008023007080090000200000120900",
"3390200800000700029700300050000000930000412000056000000070004002410006000003007084",
"3200906001010000040004000800300207004029000350800503006007000600030000080100702003",
"3000000000260000071010509080003402100000308000001607900030205040850000062000000000",
"3050096000000000004001083500908000000206050109000000406004160200100000000000270060",
"3000918006386700000002000000004300070060070050010004800000000700000007649900436000",
"3060201090009000500120000068700403002000000000300806004490000086008000200010708040",
"3002578000000001800060000002150206009800000001300107084200000070005900000000714200",
"3570000000000013000400007580600000030000984000020000007081200009000130000000000054",
"3050060000120800000009700600070003000590000072000400050003001500000006017000020030",
"3042000180000080043000510000000007400930000052007100000000042000170050000029000360",
"3400103009002806300100000008010050030200070005070060020600000003001605900500702004",
"3900200000800300004035906000000000870060000030057000000000803640300002005000001002",
"3020000500806700024005060000002400070000605000090008100000020700570003209001000030",
"3000008007817002000000050014702090105000000000508070302370080000000400973400500000",
"4010008407950000000008010000082000000700406008000000620000050700000000082503200010",
"4750090046901000302000000000200601007080000020100308005000000000309000204840030079",
"4000890020009005007050000300093500100000107000001006840008000060900600400010028000",
"4080790000000002090003008450008000001096000370300000200032500900040800000000064020",
"4000400002004012009070008000020090170000080000061050040000900050600120300100003000",
"4100034009740000000000080200090720150000000000017093020003050000000000096600970005",
"4060000027000510000700800009540070000000408000000030082300002001000063000690000030",
"4000340000200000407070008005003001002009060800700200300500600010102000009000014000",
"4080000020001000600200050003006501200700604009004709300600010005007000900040000030",
"4019200500700080300040500000300000000020107080000000001000004050005010006002006790",
"4090568020000000000056000790300409007000000000400201008074000510000000000020134070",
"4100000004245000708030500000900003100000807000007600002000009040402000653300000009",
"4001400000000078601000050900080000023013000560950000070005040000309180000000007300",
"4100000009060807050007000200210050093000408000430020087001000900050609040600000008",
"4000080020400007900803400000000005001940010052500300000000009703009800004030060000",
"4400000100002600400670000092020004000010709060000300020130000079007005300008000001",
"4009000002000310800208600000050020001000408000600090040000006403007085000100000200",
"4000002900008040070000607030040000050053809260010000090030204000070050600005700000",
"4050030000001600908340701000000007005090000080700200000000309061604008300000060070",
"4800040103000500700130000000000206080500000004020407000000000031002004000604070005",
"4007300200300000001800620000073400005000000000500008490000067004200000006009004300",
"4030000740000000080000485620200009000060104030000800009096731000020000000017000060",
"4100000000002300074000200085600870050000906000090024003580002000940007800000000006",
"4300100004000000090002009030100200700003000800008006001010400200050000000400007008",
"4460001000002096000030000068000000037000607000510000000840000050000710900000300024",
"1080001600070400021500396000204050130008907500057030902000563009310002050005800040",
"1012680090600004010805200370000007523000406000381900000054002801070300002030059760",
"1047050008605030201000706030006070024900804006450010900010502000208040503500090710",
"1009001620570028030300700004890070400060503090001090076600007008040130065027600900",
"2390010048840905062000000000009108200020000050001604300000000000580701023210080097",
"2480010029001209500600000003070050030009304700010020090200000001003806900950030067",
"2046090510002301900000605000670000054080000060520000098000704000005209800061080720",
"2001000500080006290630200004050809700000010000009507030500001069093700010002000300",
"2910000037002000600800609005090302050004080700060701080600208004001000300250000019",
"2803001000000000400100028003904060017000405000210080306300270005009000000000800602",
"2008000600050040080790608045400050006000201000200070003910507038030060020004000700",
"2000007004800000060540920001459010003200000009100030482700058096010000005600700000",
"2000904000092563810600000005500408003070000050200709001700000004014385760000207000",
"2003000040410005020000092003041050000009803400000070680200760000060200098030000700",
"2000002385070000009000008061700010500050709030001030008810600000600000020935400000",
"2301000209000106000540000081000613000200905003000842000190000035000408000402000807",
"2020000010000805000801000604032704590600000008085209170208000409000401000090000050",
"2200000008005302400090105020053060910002000300086090570060708040009604700300000001",
"2000002930000000015046000007060804009008107600400209050300000290790000000025300000",
"2206907000095000630000030200050040001000302000400070060001060000079000180000108409",
"2000400083050790006200800400700030008001000200500040007007006001900014030140009000",
"2804509601091000740000030000700408006003000900400903002000090000076000580902807103",
"2093006080000400302000010009000050203037040160402030000300080000509002000060300420",
"2004300280920086050600000001040000009010020070300000040800000002060250013095003700",
"2000000010000097604073400500200030040004916200050080003009002850402560000030000000",
"2000020000042901830030000070300274005800000002500896003050000060071603590000080000",
"2004700001601000580000095300060040010408000702010050090006510000089000203700002100",
"2207900630310004000600100000004509800000020000002807900000001005000300027093005108",
"2950080043800605009000903000620000054004000700190000032000702000400501008230060017",
"2400701006720000089006000500090105060000938000070604050007000600130000048600203005",
"3800000004020000070009106500006208900090030040002407800007905600080000020600000009",
"3001905000090200680000000049000040501000000000708050000560000000043008070000106400",
"3000700080080009050002004030000540600600030001003078000030400700010300090020006000",
"3000000000250080064003602900039000620000307000061000450006409700370050092000000000",
"3080400093002060000005800700800200007070000020500003004006001200000040900140008070",
"3000070460600008000008030010400300020085000730030009004040060300000500007056010000",
"3080000030002800500700000012000180006005000200200097000640000008001004700090000020",
"3601005007009070000000000024300604000040000080000901005810000000000050700500300108",
"3000060000900300400700490200400920060006000500030084001003016004002008007000030000",
"3609500000002190040040000000800070400000602000005080001000000070090048300000001506",
"3009000000608003004010908005701000000040080020000000503800209040400100906000000200",
"3000003006003020000290500000900004060300801005070900003000005097000060800400100000",
"3800005093400000100050002000908010000000607000000020407000300020004000008310500009",
"3809001600000900030500080400008003000010020050000400700001050006060002000007800209",
"3000040700007001050008302000100000000045603920000000006000905200090400300002010000",
"3900002000100500004003000570000008690600000002014900000059000400200001006000300005",
"3000000000701000805500819007004607300050000020007103500600985002409000608000000000",
"3000200000028007500090014000160000000200301007000000084000540090003800650000006000",
"3045000000000020790006030004000002530010000040059600000400010300067090000000000480",
"3076000000000840007409000030702008040000000000030600809040000603500072000000000250",
"3000010000760000590105000800000790010003000200080061000008000703074000086000030000",
"3090000023000700080003900007107060000060040070000050608200001900080004000310000050",
"3390004000000000900000502007250030090010000040070040085700901000001000000000800053",
"3008000013000600500107090000050003069000000000320400070000050804005006000840000600",
"3500030609020007400000000020001003005000286000600700900010000000007100040403090002",
"3000080063004703001060000009030000206000030000502000080400000010600801700910050000",
"3008000300000391000010802070250000031000030000830000056040106080000489000005000600",
"3700000000006750209004090000400002090080000020050800003000010500103048600000000001",
"3000000400000810000800063970010000704020708060706000090089420003000096000003000000",
"3000730200020050080700400000000000605630000047108000000000009003090020060005076000",
"3800732001000000000190000028004501600700000004009407100240000036000000000900128007",
"3006000004020060007301008000004005030007000500090600800000800602100090050500000900",
"3008000000070006500506008100300070010040000090010050002003700801009800070000000400",
"3000004009460800003001090004000602070000000000020503000800010900100007042300900000",
"3500000900000200001000130520020000007009406300400000010054069000900001000006000003",
"3060300010035600200000008900000005070090080060080900000003700000006001420010002080",
"3400003000000260009508000600820000010007000200010000063004000508100082000000900004",
"3302008000950006000000031400000000230800000009067000000006570000000100085000200901",
"3001040200000703000305000801020000080000609000090000050506000103000501000008060400",
"3000006500827000001000027000008600000510000067000001200000790000600000829004500000",
"3000002500304680000100000600051040000070060040000010780007000009000028103008700000",
"3000360700080000020000907001000030100036000480005070000700209000050000060002046000",
"3040108200057000000000002600004600000608000409000007500001300000000000730009501060",
"3080007050090810000065200000000460000000300200000008700000004890000056030070900040",
"3002060000006007009007008400900030001300502004600010003005300800800600500000020900",
"4000050000009006800057000240080904000200060003000308010048000350001400700000090000",
"4036000740000605000200000009705000201000209000902000403300000002000908000071000950",
"4000000008003970000600030020800200070079000240010007009060050004000042900500000000",
"4046000890000000000007953200070030050000407000090020080002741500000000000051000430",
"4800000003000700000002004189008000000709601802000000300651300700000002000200000001",
"4056000000100700200000092000014080000800000009000040350000530000009008002000000160",
"4007090000080000102600002040400000009000346000500000007050900003301000020000060800",
"4000000300000900070009050081410006000060070020000200054140030200080002000005000000",
"4300006000000021000860007320024000000900000003000000670093100052000750000000800006",
"4005430010100002000700000009080000020300000006020000030200000008000900007040081500",
"4010000008630000400005700600000600030000239000050001000008004300002000095900000020",
"4200000000090800056007300019000430080000000000040059000720001300180005070000000005",
"4305001004002008000000060082940000000003000700000000043250010000000500900100400307",
"4004870030210009000003000000060500000401000905000007020000000100000200078050086400",
"4710000000209050600000008090006032000008000400000180900030700000004010708000000053",
"4000673000300000004007000900010702080004090600080106090005000300200000007000429000",
"4000005090006100003014890000960000000000020000000000072000018640700009200020300000",
"4000009000030010006090280400059006003000000000800700940004025030200070050000800000",
"4005000400800000003030802090000308000207040301000709000040605020600000005009000100",
"4010008006000000003000075400002004080046000790050900100005360000800000000900800050",
"4000600050804000600020080030000703004006050100300108000070010020002000301090007000",
"4002090000080600001000010680700000000050206040000000008069070000500009030000030700",
"4000910406500006000104080000700000050010000080020000003000060109000500002401073000",
"4000070001640002009008000000803500000004080900000009706000000300900100062500040000",
"4000057080300000000002900400200809300400000007007406008006002700000000005090310000",
"1800500320703100400120009008650093080090000010080620093200400067006008102074006005",
"1710005006009260034002900800500040620100703009083050007005008300430072900900400051",
"1010007540400850007605030100700506030024000860080102009009070405800019006043600070",
"1902070800004009060130500002400850010089401670010036008800002036050600900007040201",
"2000000300080003009024070086900005408000402000106900005560030140400500090007000000",
"2000002100069040070400010060300805000091000730000901005070050002030020410002400000",
"2350180020000700019000000700004801070900040008080602900005000000890005000030027056",
"2010000020005401900806090705700304006020000070400709001907050308002608100080000050",
"2708010904000000000032000670400109007006208400200503008093000210000000000607090503",
"2100000049000800000820700613000009506060000080509600000485007092000002000790000004",
"2008271600006000800700000005200103006350609047800705003100000004005000300009857100",
"2003408200070102040010000060300040006702000805500020003030000050050607030009504100",
"2009000100500070004007915800902000408070208030305000207008394700400060009006000300",
"2090010250007000800000908003040086002001000600900420010600805000008000900052070030",
"2100200073600079000004000500090103008080000040300602010007000100000950007830007005",
"2520000036001806400007040500040603080002000900050401060006030200008207600270000014",
"2700060005324000698060000020007304800000106000006902500030000050642000783100020009",
"2000610000000080496690000007706000080150000039020000704200000078861090000000063000",
"2014000300000800940200060508000005090071000280060900000105020004023008000009000860",
"2564001000000009806000034000700040083050000090120080005000470000802500000000200537",
"2000300008530700004004008209051000000090000080000000350407800600600002017300004000",
"2013000570900506001600000003070080050109060807060040030800000002200807005036000910",
"2258000009000910002000008007004080090070163040020090500300400000100075000700000126",
"2010003608000100005003020904302500000800000002000004103107050800200009000905300070",
"2469000000530007800000200060000713008800000003600548000020009000004600057000000239",
"2036100000000070003007540201000000705073000810208000000702019400600020000000006150",
"2000000000100304009073592680009040100608000705004070800062189430900703008000000000",
"2070000050008000900400201008280453097000000000130687042600509003001000400050000060",
"2000300900000006100067950008200090053300000009810060007100028730002600000003005000",
"2000050009050007200000008650904700000068401970000006805071800000006500090400030000",
"3700000009000183000530000064060908030100000005050207040370000018000826000600000002",
"3020000000009630580000007000900040003100805009700020006000400000035092400000000070",
"3030700001000000720040061090005000603000604000601000200060120070098000000100009080",
"3000285030040000090800070000200006000504000109000100004000040002070000040010528000",
"3000500600000900020152000900009020008000408000600070300007000186020007000008005000",
"3000000000008304700370000098960020075000010000540090036420000087003805600000000000",
"3080040600000200708960000000000060050300102007040030000000000091502009000008020040",
"3009502080001080009040000100100006400090000010004100002005000020700050600020408700",
"3980000000071000002005040000034007000010406080000100650000090300700000820000000067",
"3000000000000020080004009520007460059003000100560098400039100700020030000000000000",
"3047800000810000067000000005000043000054070180000590000600000000530000091000007350",
"3040050030950000012002000600800506009000000000100704005003000800280000097070060040",
"3000009000106008000000074209500000040007201500080000001804510000000400608000700000",
"3501000906700060003000702000003010500050080040008020700000806000800070009609000305",
"3050400209000005004070060000900000058004070300820000007000090060600700000102006030",
"3001000300002000700000823000200080006010405070300070004000762000007000500008000400",
"3930060005010000038000800000000502800700000009002104000000001000140000020500020087",
"3007004008008000003000061200000040070204000309090020000006190000500000800900700600",
"3030000005089030100200000000900007506000605000502300004000000009007010230600000050",
"3090000003203001000170098000004000000900603004000000500000420036000900402600000010",
"3000010004000980720000004050007000006860050071200000800070300000039048000500020000",
"3680000000010742600003000000000200007870405032400008000000000300001896070000000014",
"3080904010003070200000608000700010002002000700300050001000807000001040500060105020",
"3094000000100790000003086001920000030000070000080000025400520900000061003000000640",
"3001400080050010000020003007800050400300000001007090008600700020000030060030006900",
"3100009008007000390004070000005200040900000005020008600000010200059000700600800009",
"3302900000008000009000001060000039076050000080130850000090200000700000400000006103",
"3000406000790000036080030090040070050602000108070080020060020080320000049000809000",
"3003000100071908350000050000060804030400000001010605090000030000098201740006000200",
"3800000006320000048000109000010208050008090600050601080000307000540000032900000001",
"3006070800000000000078601520030405010400000002090302060052103690000000000003020100",
"3200050000030600500106030000307009000008060200000800407000020805005003070000090006",
"3008301900000705000060000070704000809200406005601000203010000020000108000005907100",
"3230700010000000400060040050009003005000908000800500900070020030006000000020005081",
"3000507000001000400460010095800109007007000500200305004120090046008000900000801000",
"3308000006000001000000650007080040600002907100007020090400076000000400000900000305",
"3800003009000008402630010000000000890005000600073000000000060021407200000300700006",
"3060309010003070800000405000702000509050000060601000207000206000008010600040803020",
"3007004000000005000560000109280700000904000306000001098702000031000600000000400700",
"3007002000580007000040800607692000000000030000000000291703004050000700089000600400",
"3000005107490000000008290000050060000100708003000030020000016900000000068805900000",
"3700360000500000000090204006000800079060000010470005000800103040000000002000097003",
"3107200083000000000008009060000790030001000200080052000020500400000000000640001702",
"3001002040300500600090000007900010080000248000020060003400000030003001008050700900",
"3405000109010009030000600000670050000080206090000090015000008000050900020103000406",
"4801000500200009040530000000000290000004000100000041000000000092050700008008000403",
"4001000000003200004900030020007005013009000800350600900090040006400008500000000300",
"4500600000800003760002001000000030571000000000275060000000200300031400002000009006",
"4900200006100500700083000000000030800300701009009050000000000190001002008200008005",
"4004000701000030000070085000000500003085020670600008000000240030000090000409000800",
"4650090020000007000209000000007004000005706800000200100000000307000600000030010098",
"4001000000500040000020318000086200004070000050400003860000486090000090002000000700",
"4100050043008200010050000600000001090400000007020300000004000080090007500870020004",
"4000600900040510006090082000502000000300000001000000802000190040600023050009006000",
"4000000000004605800802000501300208007000406000200501006706000409008309600000000000",
"4000475000400208009070000020300000001015000340200000008060000080100307004000812000",
"4800002040000080003000000160000000031005967200240000000031000000600090000050100007",
"4904000020005900000020008006009000058000080000640000100100200090000001700070000604",
"4003000100580000042000907000040030010000284000020070030000608000710000063008000500",
"4083100050000000260500940000970000000000203000000000078000081009046000000030004610",
"4000009030008010007060030002790500000004000100000008045400050020600040500050300000",
"4200901003500000007000408000060000040000135000080000090000309000800000006900502008",
"4100608002000000030436100000005000090000402000040000800000009175090000000600207009",
"4006703500800010009040000080002000700000924000004000900020000010700040003009106400",
"4000000780060710040500020000002001000080502030000400600000080001040097020036000000",
"4000000000030104050047060830600802007000000000400709002075030620080907010000000000",
"4800210000000400190007000000600008903300000005708600001000000800013005000000064007",
"4002093080074006000000400050000000020001308500090000000060004000000900870050870200",
"4100500000600210500000809002008000300007000100005000900400308000003021009000004007",
"4361004000000300006070000009002010050009000600050020800600000010800007000000900564",
"1050480062800003500032070001047500028000908000690007430300010640001300007280069050",
"1200804005007203400045000620310040069000902000950030072079000380008501200400307006",
"1006050203800001059100630040008400762000502000472008900050087001930200008207010400",
"1005009300027010000100620840600002530509304701032800009074096005000030170008500600",
"1080400700006039008409010520070050001052706380900080070047020803200140600005003090",
"2000604000501000408060503020400302006305000704800709005040906050607000802000801000",
"2200000003003041500090500060060203100020000070005906080030005090001720600600000005",
"2000000740090506010812700000050004007600080003100300020000003476080401090065000000",
"2509007040000290300070000100021940070000030000040078510007000080006021000050700409",
"2400000002027408910000792000380000095009000600640000071000631000018509340200000009",
"2003000100690304082020080070400901008030000090200803001040090010980407035005000600",
"2031000720004060300000109000208503407010000030307604802000706000009020100065000270",
"2500000004003286500901000302040901030200000005030805020706000408002614700300000009",
"2900070006100908005003060100070681020005000600010592030007050900600209003500040008",
"2000050000320409065070000010047080630000502000069040150010000080830607049000020000",
"2041008002020410000030000005000501709005000600409207000300000010000082030600700490",
"2070060040000109000025000760501607304000502000209804605097000280000901000010080090",
"2400000007060849020900020003070592030009000200040683050700010008080734010200000004",
"2609000402020709010008000500900304005000010000300607004007000600030501040401000309",
"2000029000600000005019600300078500049001000500450007280002001690300000002000730000",
"2005000800140208063020070050080501070003000100050603040060020010510807094008000500",
"2370000028000108000082000450060030080003261700040080090034000570000905000710000069",
"2200901005009208600080000040802000407370000098906000503020000010005602800700104002",
"2000000002610080407003004065305060000009205300000040208150900700906070083200000000",
"2300400002051007090009000830090708005000000000800204060042000100070100320500006009",
"2007350006830900400000000080300600100005801200002003009010000000006007045500064300",
"2030001670079000000218000004040009300900010002001200050800000745000000860095800030",
"2600020004000903000390506028960000083000102000240000016120807039000601000700030005",
"2026080000000004000740036082308000000001703400000000205130620059000300000000040860",
"2506040709000603000900000004102307906008000400305804201600000007000906000409020508",
"2109004608000008010600020503802003000005000300000800109508090004090600000301400705",
"2030000010507201809009000400005908300400000007003105200008000600102307504090000080",
"2000000043092004000040060827100002050050309070070800002327090080000400760410000000",
"2500804002060000030003906700800702001000000000300405006002307900050000010100609008",
"2902807601050203040800010007060000050000604000090000010600080004070306080308705902",
"2DB  A  CH C     G   A D E  E DC HF A         B FG AC E  G C D   D     E IE  H  FB",
"2 C      B BDG FC      B G  D GE     H  D A  F     IB D  H F      FI CDH C      A ",
"2A       I  FA BH   D I E G  EB   FH    F C    AD   IC  G B A F   CG DB  I       D",
"2  FH  I     A  FC B     G E   GI   FG   B   CH   FA   E I     G AD  G     B  CD  ",
"2F A D B I IGA FED           H B I F  C     E  A E C G           GDH BCI C I E G A",
"3000004000502006070006801004300040750000000000089060002400607100070200603000400000",
"3000704000003000200068000470120803047000000000980501062054000630002000100000908000",
"3010940006069003000000008900000060005807000201500080000002800000000700430700014020",
"3700608005004000700069000830000456000050000060000823000073000610008000900200907003",
"3040060030650000098003000500009050600060803050002070100004000200120000046080040010",
"3000070013009031060070800000000003072000040000620700000000008030080510900140060000",
"3019005002000003008000000490002071004000209000600850300093000000200300000500900640",
"3005600002030000600000240900060900028100000006250004070009071000001000090400005700",
"3100000035000705010000009700000020170006000800025060000003100000050603000680000001",
"3010000080000702000500090004307000102008306400605000809700030006000108000030000040",
"3900030000070008900002050001000075042030000010740310000300040200006100070000080004",
"3000000870008200001900870000040060530000000000076030080000084002500002900013000000",
"3100900035070003020006010000300060000250000083000050009000030800090600040580007001",
"3060000000970800620001003005604010200000000000005070801300700400056008017000000060",
"3000200090016008400700003600640070800000000000007060035008400009004100250070002000",
"3100203009006000200003708400600000003039000170400000005004802700001000900200409008",
"3009030100750000049010000070800261007000000000400597003080000050260000018007080600",
"3290000017000703000070000060600050003930080046400060002050000080000605000340000021",
"3030050040209000308007000600000104000080000010000807000006000400508000107040030080",
"3004090050009030000500800006100025600002000700005340009800002004000070500050060300",
"3024000000690080004000090800001500009000109000200007500005020000100070036000000790",
"3000002600030004000090008005050040029070903060980050070700400010000600080001300000",
"3023000670700000005000784000005602900060000020008307100000421000500000001031000280",
"3060000000003094000100002500007000080405030102030000600002800001000640900000000070",
"3900008040000010080800005001509400130000000000021003705700600002030080000050300008",
"3000000025008009000000503010600050078080000060520040009030704000000100400790000000",
"3400200075301900000000800020000000817000000000247000000060005000000001708810003009",
"3000895000003000200400020007098000340000401000034000120600040002001000400000687000",
"3000200790700010000310600000409030000000401000000070806000006025000040009057009000",
"3200005004930207800000080200000002430000000000045600000008020000006109085700400009",
"3060005200001007000000600840300069500090000030008540002075006000000900700006800010",
"3300000004080000060006305700010602050900000007050801040009504100060000020100000006",
"3958000000000000002630910000000025608001000700804160000000052087700000000000000496",
"3804050607000000000009203400060000010100806003040000090007908300000000000602070108",
"3000574000100060002570000084090080040001000300020040090380000017200030006000758000",
"3000041900010000006409730010000006203000000000304900000080097602700000050005360000",
"3000000000047000150095107280000405000750000043000801000038602470072000930000000000",
"3000400708103580200900300000000000097050000040310000000000008003008065902205009000",
"3014000830008000700900107004000804000600070003000902000500608009006000500082000310",
"3000000800001002609080400000902005107300000006608700402000009070807500200006000000",
"4020060070400005001005003800072000000800010002000000490009400600300100008050080040",
"4000000000023090640010708020009000400080405090005000800060802050041060230000000000",
"4012800000093000400040003000100034000050000030000170009000600020001000740000005810",
"4000048900004200010000300080900000640005000700038000002060001000020005300009820000",
"4000000000004805200980000061030201070600000009070409080450000023006702800000000000",
"4000000000859000003000700801060400700500030009008005010903004000100000367000000000",
"4500080400060200050090000000100300002004107800200008007000000010020004030009070004",
"4079000200000201000000030050604007001001000600300400702050040000000309000006000490",
"4000503000900000008051000260006020900000736000003090400029000310500000002000902000",
"4800006100300000700900705000002070084000000000470090500000502006001000008004100007",
"4060509010009030200800000007001000500090601040007000300900000005005090400070804020",
"4200105003000000000009307200080060030070000050050070090007901800000000000100602007",
"4900003400000000700050081000600100904700000008208004006000350020001000000002400007",
"4031000000020000437050070009000309000008000600000805000400020080687000040000000170",
"4007000002001080096020009300000004000005906100000300000002800050140050700700000600",
"4000009040002000076900705000000007020300000008040100000000306005120000300090800000",
"4000900800490000000500030070000200100008401200006007000060050003000000042004008000",
"4040090705003000010010000000600004001007602800200500003000000020050000900309070080",
"4500008000804300060000010008056040000000000000000030820200050000010009406000400005",
"4090300000010090050008050070000000108600908003904000000020070900060040020000009080",
nil
};

- (id)init {
	self = [super init];
	if(self) {
		for(number = 0 ; ; number ++)
			if(glist[number] == nil || glist[number][0] == '\0')
				break;
		
		if(number > MAX_GAMES)
			number = MAX_GAMES;
			
		NSLog(@"Question.num = %d\n", number);
	}
	return self;
}

- (char *)get:(int)i {
	if(i < 0 || i >= number)
		return nil;
	return glist[i];
}

- (int)number {
	return number;
}

- (bool)finished:(int)i {
	NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
	NSString *logFile = [[NSString alloc] initWithFormat:@"%d.log", i];
    NSString *filename = [documentsDirectory stringByAppendingPathComponent:logFile];
    bool res = [fileManager fileExistsAtPath:filename];
	[logFile release];
	return res;
}

- (void)finish:(int)i {
	NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
	NSString *logFile = [[NSString alloc] initWithFormat:@"%d.log", i];
    NSString *filename = [documentsDirectory stringByAppendingPathComponent:logFile];
    if (! [fileManager fileExistsAtPath:filename]) {
		[[NSFileManager defaultManager] createFileAtPath:filename contents:nil attributes:nil];
    }
	[logFile release];
}

#pragma mark Robot

- (void)reset {
	NSFileManager *fileManager = [NSFileManager defaultManager];
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
	
	int i;
	for(i = 0 ; i < number ; i ++) {
		NSString *logFile = [[NSString alloc] initWithFormat:@"%d.log", i];
		NSString *filename = [documentsDirectory stringByAppendingPathComponent:logFile];
		if ([fileManager fileExistsAtPath:filename])
			[fileManager removeItemAtPath:filename error:nil];
		[logFile release];
	}
}

- (bool)isExisted:(int)i :(int)j :(char [9][9])myBoard {
	int k;
	int l;
	
	for(k = 0 ; k < 9 ; k ++)
		if(k != j && myBoard[i][k] == myBoard[i][j])
			return YES;
	
	for(k = 0 ; k < 9 ; k ++)
		if(k != i && myBoard[k][j] == myBoard[i][j])
			return YES;
	
	for(k = (i / 3) * 3 ; k < (i / 3) * 3 + 3 ; k ++)
		for(l = (j / 3) * 3 ; l < (j / 3) * 3 + 3 ; l ++)
			if(k != i && l != j && myBoard[k][l] == myBoard[i][j])
				return YES;
	
	return NO;
}

- (bool)isFull:(char [9][9]) myBoard {
	int i, j;
	
	for(i = 0 ; i < 9 ; i ++)
		for(j = 0 ; j < 9 ; j ++)
			if(myBoard[i][j] == 0)
				return NO;
	
	return YES;
}

- (void)showBoard:(char [9][9])myBoard {
	char buf[256];
	int i, j;
	
	NSLog(@"\n");
	for(i = 0 ; i < 9 ; i ++) {
		memset(buf, 0, sizeof(buf));
		for(j = 0 ; j < 9 ; j ++)
			sprintf(buf + j * 3, "%2d ", myBoard[i][j]);
		NSLog(@"%s", buf);
	}
	
	NSLog(@"\n");	
}

- (void)showAnswerList:(char [9][9][9])answerList {
	char buf[256];
	int i, j, k;
	int off;
	
	NSLog(@"\n");
	for(i = 0 ; i < 9 ; i ++) {
		memset(buf, 0, sizeof(buf));
		off = 0;
		for(j = 0 ; j < 9 ; j ++) {
			buf[off++] = '(';
			for(k = 0 ; k < 9 ; k ++)
				if(answerList[i][j][k]) {
					buf[off++] = '1' + k;
				}
			buf[off++] = ')';
		}
		NSLog(@"%s\n", buf);
	}
}

- (void)calcAnswerList:(char [9][9][9])answerList :(char [9][9])myBoard {
	int i, j, k;
	bool bExist;
	
	for(i = 0 ; i < 9 ; i ++)
		for(j = 0 ; j < 9 ; j ++) {
			if(myBoard[i][j])
				continue;
			
			for(k = 1 ; k <= 9 ; k ++) {
				myBoard[i][j] = k;
				bExist = [self isExisted:i :j :myBoard];
				myBoard[i][j] = 0;
				
				if(! bExist) {
					answerList[i][j][k-1] = k;
				}
			}
		}
}

- (int)pushStack:(char)i :(char)j :(char)digit :(char [9][9])myBoard {
	if(stack_num >= 81)
		return -1;
	
	stack[stack_num].x = i;
	stack[stack_num].y = j;
	stack[stack_num].digit = digit;
	memcpy(&stack[stack_num].board, myBoard, sizeof(stack[stack_num].board));
	stack_num ++;
	
	return 0;
}

- (int)popStack:(char *)i :(char *)j :(char *)digit :(char [9][9])myBoard {
	if(stack_num <= 0)
		return -1;
	
	stack_num --;
	*i = stack[stack_num].x;
	*j = stack[stack_num].y;
	*digit = stack[stack_num].digit;
	memcpy(myBoard, &stack[stack_num].board, sizeof(stack[stack_num].board));
	
	return 0;
}

- (int)tryAnswerList:(char [9][9][9])answerList :(char [9][9])myBoard {
	int count = 0;
	int i, j, k;
	int num;
	int ret;
	char c;
	
	for(i = 0 ; i < 9 ; i ++)
		for(j = 0 ; j < 9 ; j ++) {
			num = 0;
			for(k = 0 ; k < 9 ; k ++)
				if(answerList[i][j][k]) {
					c = answerList[i][j][k];
					num ++;
				}
			
			if(num == 1) {
				myBoard[i][j] = c;
				if([self isExisted:i :j :myBoard])
					return -1;
				
				count ++;
			}
			
			if(num == 0 && myBoard[i][j] == 0) {
				//NSLog(@"no move.");
				return -1;
			}
		}
	
	if(count > 0) {
		//NSLog(@"advance #%d", count);
		return count;
	}
	
	int off = 0;
	if(stack_num >= 1)
		off = stack[stack_num-1].x * 9 + stack[stack_num-1].y + 1;
	
	for(i = off ; i < 81 ; i ++) {
		if(myBoard[i/9][i%9])
			continue;
		
		for(j = 0 ; j < 9 ; j ++)
			if(answerList[i/9][i%9][j]> calcLine[i]) {
				ret = [self pushStack:i/9 :i%9 :j+1 :myBoard];
				if(ret)
					return -1;
				myBoard[i/9][i%9] = j+1;
				calcLine[i] = j+1;
				for(k = i + 1 ; k < 81 ; k ++)
					calcLine[k] = 0;
				//NSLog(@"try (%d,%d) = %d", i, j, k+1);
				return 1;
			}
		
		return -1;
	}
	
	return 0;
}

- (int)discardAnswerList:(char [9][9])myBoard {
	char i, j, k;
	int ret;
	
	ret = [self popStack:&i :&j :&k :myBoard];
	if(ret < 0)
		return -1;
	
	//NSLog(@"discard (%d,%d) = %d", i, j, k);
	
	return 0;
}

- (int)robot:(char [9][9])board :(void *restrict)myBoard1 {
	char answerList[9][9][9];
	char myBoard[9][9];
	int ret;
	int i;
	int j;
	
	for(i = 0 ; i < 9 ; i ++)
		for(j = 0 ; j < 9 ; j ++)
			myBoard[i][j] = board[i][j];
	
	memset(&calcLine, 0, sizeof(calcLine));
	memset(&stack, 0, sizeof(stack));
	stack_num = 0;
	
//	[self showBoard:board];
//	[self showBoard:myBoard];

	while(1) {
		if([self isFull:myBoard])
			break;
		
		//		[self showBoard:myBoard];
		memset(&answerList, 0, sizeof(answerList));
		[self calcAnswerList:answerList :myBoard];
//		[self showAnswerList:answerList];
		
		ret = [self tryAnswerList:answerList :myBoard];
		if(ret <= 0) {
			ret = [self discardAnswerList:myBoard];
			if(ret < 0) {
				NSLog(@"ROBOT: no move!!!");
				return -1;
			}
		}
	}
	
	memcpy(myBoard1, &myBoard, sizeof(myBoard));
	return 0;
}

@end
